<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>项目管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(function() {
			
			$("#inputForm").validate({
				rules: {
					name:{required:true},
					manager:{required:true},
					typeid:{required:true},
					starttime:{date:true},
					endtime:{date:true},
					describe:{required:true}
				},
				
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		
			//当页面加载完成的时候，自动调用该方法
            window.onload=function(){
                //获得所要回显的值
                var checkeds = $("#sp").text();
                //拆分为字符串数组
                var checkArray =checkeds.split(",");
                //获得所有的复选框对象
               var checkBoxAll = $("input[name='typeid']");
               //获得所有复选框
               for(var i=0;i<checkArray.length;i++){
                   //获取所有复选框对象的value属性，然后，用checkArray[i]和他们匹配，如果有，则说明他应被选中
                   $.each(checkBoxAll,function(j,checkbox){
                       //获取复选框的value属性
                       var checkValue=$(checkbox).val();
                       if(checkArray[i]==checkValue){
                           $(checkbox).attr("checked",true);
                       }
                   })
               }
            };

		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/projectdemo/projectapply/">服务器申请列表</a></li>
		<li class="active"><a href="${ctx}/projectdemo/projectapply/form?id=${projectapply.id}">服务器申请<shiro:hasPermission name="projectdemo:projectapply:edit">${not empty projectapply.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="projectdemo:projectapply:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="projectapply" action="${ctx}/projectdemo/projectapply/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" name="status" value="0"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">项目名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">项目英文名缩写：</label>
			<div class="controls">
				<form:input path="abbreviation" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">项目经理：</label>
			<div class="controls">
				<form:input path="manager" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">服务器类型：</label>
			<div class="controls">
				<form:checkboxes path="typeidList" items="${alltype}" itemLabel="type" itemValue="id" htmlEscape="false" class="" id="firmType"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开始时间：</label>
			<div class="controls">
				<input name="starttime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${projectapply.starttime}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结束时间：</label>
			<div class="controls">
				<input name="endtime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${projectapply.endtime}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">项目描述：</label>
			<div class="controls">
				<form:textarea path="describe" htmlEscape="false" rows="4" maxlength="1000" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="projectdemo:projectapply:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="window.location.href='${ctx}/projectdemo/projectapply'"/>
		</div>
	</form:form>
</body>
</html>